/**
 * Vue3 简单状态管理
 * @see <a href="https://v3.cn.vuejs.org/guide/state-management.html">从零打造简单状态管理</a>
 */
let store = {
    debug: true,
    state: Vue.reactive({
        runTask: null,
        apiDocs: null,
        lastMessageTime: new Date(),
        healthState: true,
        queryHash: '',
    }),

    setRunTask(newValue) {
        if (this.debug) {
            console.log('setRunTask triggered with', newValue)
        }

        this.state.runTask = newValue
    },

    clearRunTask(newValue) {
        if (this.debug) {
            console.log('clearRunTask triggered with', newValue)
        }

        let {runTask} = this.state;
        if (newValue && runTask && runTask.id === newValue.id) {
            this.state.runTask = null
        }
    },
};